<?php

use common\helpers\Html;
use yii\widgets\ActiveForm;
use kartik\select2\Select2;
use common\enums\StatusEnum;

/* @var $this yii\web\View */
/* @var $form yii\widgets\ActiveForm */

$this->title = '审核';
$this->params['breadcrumbs'][] = ['label' => '待办工作', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
//Yii::$app->debris->p($model->getWorkflowStatus()->getId());
//Yii::$app->debris->p($model->getNextStatuses());
$status = true;
foreach ($model->getNextStatuses() as $key => $nextStatus) {
    $status = false;
}
//Yii::$app->debris->p($status);

?>

<div class="row">
    <div class="col-lg-12">
        <div class="box">
            <div class="box-header with-border">
                <?php $form = ActiveForm::begin(); ?>
                <?= $form->field($model, 'covers')->widget(common\widgets\webuploader\Files::class, [
                    'config' => [
                        'pick' => [
                            'multiple' => true,
                        ],
                    ],
                    'themeConfig'=>[
                        'select' => false,
                    ]
                ]); ?>
                <?php ActiveForm::end(); ?>
            </div>
            <div class="box-body">
                <?php $form = ActiveForm::begin([
                    'fieldConfig' => [
//                        'template' => "<div class='col-sm-1 text-right'>{label}</div><div class='col-sm-11'>{input}\n{hint}\n{error}</div>",
                    ],
                ]); ?>
                <div class="row">
                    <div class="col-sm-12">
                        <ul class="timeline">
                            <li class="time-label">
                          <span class="bg-blue">
                            审核开始
                          </span>
                            </li>
                            <?php
                            foreach ($model->log ?? [] as $log) {
                                ?>
                                <li>
                                    <i class="fa fa-user bg-blue"></i>
                                    <div class="timeline-item">
                                        <span class="time"><i
                                                    class="fa fa-clock-o"></i> <?= date("Y-m-d H:i:s", $log->time) ?></span>
                                        <h3 class="timeline-header"><?= Yii::$app->merchantsService->member->getName($log->id) ?> <?= \addons\Flow\common\enums\WorkflowEnum::getValue(explode('/', $log->action)[1]) ?></h3>
                                        <div class="timeline-body">
                                            <i><?= $log->suggest??$model->content; ?></i><br>
                                        </div>
                                    </div>
                                </li>
                                <?php
                            }
                            ?>

                            <?php if ($status) { ?>
                                <li class="time-label">
                              <span class="bg-yellow">
                                审核结束
                              </span>
                                </li>
                            <?php } else { ?>
                                <li>
                                    <i class="fa fa-clock-o bg-gray"></i>
                                </li>
                            <?php } ?>
                        </ul>
                        <?php if (!$status) { ?>
                            <hr>
                            <?= $form->field($model, 'status')->radioList($radioList)->label(false) ?>
                            <?= $form->field($model, 'suggest')->textInput(['placeholder' => '请填写审核意见'])->label(false) ?>

                        <?php } ?>
                    </div>
                </div>

                <?php if (!$status) { ?>
                    <div class="form-group">
                        <div class="col-sm-12 text-center">
                            <button class="btn btn-primary" type="submit">保存</button>
                            <span class="btn btn-white" onclick="history.go(-1)">返回</span>
                        </div>
                    </div>
                <?php } ?>
                <?php ActiveForm::end(); ?>

            </div>
        </div>
    </div>
</div>

